
#include "stdafx.h"
#include "TestLogicPtr.h"
#include "DbgTrace.h"

#include "IPtrFunc.h"



void ProcessFactory::Create(const E_PROCESS_TYPE& eType)
{
	if(eTEST_1==eType)
	{
		CreateTest1();
	}
	else if(eTEST_2==eType)
	{
		CreateTest2();
	}
	else
	{
		CreateTest3();
	}
	//CmASSERTFAIL_MSG( L"Cannot Find Type");
}

bool ProcessFactory::Register()
{
	for( MAP_PROCESS::iterator it=m_mapProcess.begin();it!=m_mapProcess.end();++it)
	{
		if( !(it->second)->Register() )
			return false;
	}
	return true;
}

bool ProcessFactory::Excute(const DWORD& index, const DWORD& dummy1, const DWORD& dummy2, const DWORD& dummy3)
{
	E_PTRFUNC_HEADER eHeader = GetPFHeaderType(index);	
	if(m_mapProcess.end()!=m_mapProcess.find(eHeader))
	{
		return m_mapProcess[eHeader]->Excute(index, dummy1, dummy2, dummy3);
	}
	else
	{
		// UN REGISTERED TYPE
		CmTRACE( L"Unregisterd Header type\n" );
	}
	return false;
}

void ProcessFactory::Destroy()
{
	for( MAP_PROCESS::iterator it=m_mapProcess.begin();it!=m_mapProcess.end();++it)
	{
		delete it->second ;
	}
	m_mapProcess.clear();
}

#pragma warning (disable:4480)
#pragma warning (disable:4482)
void ProcessFactory::CreateTest1()
{
	m_mapProcess.insert( std::make_pair( E_PTRFUNC_HEADER::ePF_LIST1, Factory(E_PTRFUNC_HEADER::ePF_LIST1) ));	
}

void ProcessFactory::CreateTest2()
{
	m_mapProcess.insert( std::make_pair( E_PTRFUNC_HEADER::ePF_LIST2, Factory(E_PTRFUNC_HEADER::ePF_LIST2) ));	
}

void ProcessFactory::CreateTest3()
{
	m_mapProcess.insert( std::make_pair( E_PTRFUNC_HEADER::ePF_LIST1, Factory(E_PTRFUNC_HEADER::ePF_LIST1) ));	
	m_mapProcess.insert( std::make_pair( E_PTRFUNC_HEADER::ePF_LIST2, Factory(E_PTRFUNC_HEADER::ePF_LIST2) ));	
}



IPtrFunc* ProcessFactory::Factory(const E_PTRFUNC_HEADER& eHeader)
{
	if( E_PTRFUNC_HEADER::ePF_LIST1==eHeader )
	{
		return new PtrFuncList1();
	}
	else if( E_PTRFUNC_HEADER::ePF_LIST2==eHeader )
	{
		return new PtrFuncList2();
	}
	return nullptr;
}
#pragma warning (default:4480)
#pragma warning (default:4482)
//////////////////////////////////////////////////////////////////////////
void IPtrFunc::OnHandleMsg(const DWORD& index, DWORD dummy1, DWORD dummy2, DWORD dummy3)
{
	//un registed msg.
	index, dummy1, dummy2, dummy3;		
	CmTRACE( L"Unregisterd index type \n");
}

void IPtrFunc::MATH_ADD(DWORD dummy1, DWORD dummy2, DWORD dummy3)
{
	dummy1, dummy2, dummy3;

	CmTRACE( L"ADD \n");
}

void IPtrFunc::MATH_MULTIPL(DWORD dummy1, DWORD dummy2, DWORD dummy3)
{
	dummy1, dummy2, dummy3;
}

void IPtrFunc::STRING_1(DWORD dummy1, DWORD dummy2, DWORD dummy3)
{
	dummy1, dummy2, dummy3;
	CmTRACE( L"STRING \n");
}

void IPtrFunc::STRING_2(DWORD dummy1, DWORD dummy2, DWORD dummy3)
{
	dummy1, dummy2, dummy3;
}
